<template>
  <el-container>
    <el-main>
      <el-empty v-if="IsnoSign"></el-empty>
      <div v-for="item in allSigns" :key="item.sid" >
      <ReceiveSign :thisSign="item" @SignDel="delReceive" v-if="item.hide"></ReceiveSign>
      </div>
    </el-main>
  </el-container>
</template>

<script>
import ReceiveSign from '@/views/pageIn/message/components/Sign/ReceiveSign'
import { AllSign } from '@/utils/api/sign.js'
export default {
  name: 'Sign',
  props: {},
  components: {
    ReceiveSign
  },
  created () {
    this.getAllSign()
  },
  // updated () {
  //   this.delReceive()
  // },
  data () {
    return {
      SignIf: true,
      // 存储签到信息列表
      allSigns: [],
      IsnoSign: false, // 签到列表是否为空
      lastLength: 0
    }
  },
  inject: ['reload'],
  methods: {
    delReceive (val) {
      this.allSigns.some((item, index) => {
        if (item.sid === val) {
          item.hide = false
          return true;
        }
      })
      this.reload()
    },
    // 获取签到列表
    getAllSign () {
      AllSign().then(res => {
        // 取列表倒序，使最新数据显示在顶部
        this.allSigns = res.data.data.reverse()
        // 无签到信息,显示文本
        if (this.allSigns.length === 0) {
          this.IsnoSign = true
        } else { this.IsnoSign = false }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.notitle{
  text-align: center;
  color: orange;
  font-size: 20px;
}
</style>
